package api.user;

import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import pojo.Area;
import pojo.User;
import pojo.Useraddress;

import java.util.List;
import java.util.Map;

/**
 * 客户模块
 */
@RestController
public interface UserApi {


    /**
     * 客户分页条件查询
     * @param map
     * @return
     */
    @RequestMapping("/selectUserList")
    PageInfo<User> selectUserList(@RequestBody Map<String,Object> map);

    /**
     * 用户名模糊查询
     * @param name
     * @return
     */
    @RequestMapping("/selectUserListInt")
    List<Integer> selectUserListInt(@RequestParam("name") String name);

    /**
     * 所有客户查询
     * @return
     */
    @RequestMapping("/selectUsers")
    List<User> selectUsers();


    /**
     * 查看客户
     * @param id
     * @return
     */
    @RequestMapping("/selectUser")
    User selectUser(@RequestParam(value = "id") Integer id);


    /**
     * 新增客户
     * @param user
     * @return
     */
    @RequestMapping("/insertUser")
    Integer insertUser(@RequestBody User user);



    /**
     *修改客户
     * @param user
     * @return
     */
    @RequestMapping("/updateUser")
    Integer updateUser(@RequestBody User user);


    /**
     * 删除客户
     * @param id
     * @return
     */
    @RequestMapping("/deleteUser")
    Integer deleteUser(@RequestParam(value = "id") Integer id);


    /**
     * 联合查询客户所有收货地址和客户信息
     * @param uid
     * @return
     */
    @RequestMapping("/selectAddressList")
    List<Useraddress> selectAddressList(@RequestParam("uid") Integer uid);



    /**
     * id查询地址
     * @param id
     * @return
     */
    @RequestMapping("/selectAddress")
    Useraddress selectAddress(@RequestParam("id") Integer id);


    /**
     * 新增地址
     * @param useraddress
     * @return
     */
    @RequestMapping("/insertAddress")
    Integer insertAddress(@RequestBody Useraddress useraddress);


    /**
     * 修改地址
     * @param useraddress
     * @return
     */
    @RequestMapping("/updateAddress")
    Integer updateAddress(@RequestBody Useraddress useraddress);


    /**
     * 删除地址
     * @param id
     * @return
     */
    @RequestMapping("/deleteAddress")
    Integer deleteAddress(@RequestParam("id") Integer id);


    /**
     * 查询用户的默认地址
     * @param uid
     * @return
     */
    @RequestMapping("/selectDefalutAddress")
    Useraddress selectDefalutAddress(@RequestParam("uid") Integer uid);


    /**
     * 根据用户选择的区域查询对应的省份集合
     * @return
     */
    @RequestMapping("/selectUserArea")
    List<Area> selectUserArea(@RequestParam("upperLevelID") Integer upperLevelID);


}
